#include <stdio.h>
int main()
{
    long n,count=0;int i=0;
    scanf("%d",&n);
    while (n>1)
    {
        count+=n;
        if (n%2 == 1)
            n=n*3+1;
        else
            n/=2;
        i++;
    }
    printf("%.3f\n",(count+1)/(double)(i+1));
}
